import java.io.BufferedReader;
import java.io.FileReader;

public class Problem67 {
	public static void main(String[] args) {
		int N = 100;
		int[][] triangle = new int[100][100];

		try {
			BufferedReader br = new BufferedReader(new FileReader("p067_triangle.txt"));
			String line = null;
			int row = 0;
			while ((line = br.readLine()) != null) {
				String[] strs = line.trim().split(" ");
				for (int c = 0; c < strs.length; ++c) {
					triangle[row][c] = Integer.parseInt(strs[c]);
				}
				row++;
			}

		} catch (Exception e) {
		
		}

		int[][] maxTotal = new int[N][N];

		maxTotal[0][0] = triangle[0][0];
		for (int i = 1; i < N; ++i)
			maxTotal[i][0] = maxTotal[i-1][0] + triangle[i][0];
		for (int i = 1; i < N; ++i)
			maxTotal[i][i] = maxTotal[i-1][i-1] + triangle[i][i];
	
		for (int i = 2; i < N; ++i) {
			for (int j = 1; j < i; ++j) {
				maxTotal[i][j] = Math.max(maxTotal[i-1][j-1], maxTotal[i-1][j]) + triangle[i][j];
			}
		}

		int max = 0;
		for (int j = 0; j < N-1; ++j)
			if (maxTotal[N-1][j] > max)
				max = maxTotal[N-1][j];

		System.out.println("" + max);
		return;
	}
}
